package cn.magic.feign;

import cn.magic.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable throwable) {
        return id -> {
            throwable.printStackTrace();
            return User.builder().into("熔断了").build();
        };
    }


    /*@Override
    public UserFeignClient create(Throwable throwable) {

        return new UserFeignClient() {
            @Override
            public User getByUserId(Long id) {
                throwable.printStackTrace();
                return User.builder().into("熔断了").build();
            }
        };
    }*/
}
